﻿using System.Collections.Generic;
using System.Linq;
using CH.FourBoards.LagerWalti.Persistence.DataAccess;
using CH.FourBoards.LagerWalti.Persistence.Entities;

namespace CH.FourBoards.LagerWalti.Business.Catalog
{
    public class CatalogManager
    {
        public IEnumerable<CatalogItem> ListShopItems()
        {
            using (var pm = new PersistenceManager()) {
                var products = pm.SelectAll<Product>();
                return products.Select(product => new CatalogItem {
                    Product = product,
                    Quantity = pm.GetStock(product)
                }).ToList();
            }
        }
    }
}
